package com.liuke.question1;

import com.liuke.question1.pojo.Result;
import com.liuke.question1.pojo.UriBean;
import com.liuke.question1.pojo.UriKeyMap;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @Auther: 刘科
 * @Date: 2021/06/12/16:41
 * @Description:
 */
public class Main {
    public static void main(String[] args) {
        Question question = new Question();
        Result result = question.analyzeAccess();
        System.out.println("--------请求总量-----------");
        System.out.println(result.getRequestTotal() + " 个");

        System.out.println("--------请求最频繁的10个接口-----------");
        List<UriKeyMap> frequentRequest = result.getFrequentRequest();
        for (UriKeyMap uriKeyMap : frequentRequest) {
            System.out.println("URI: " + uriKeyMap.getUri() + "; 请求量: " + uriKeyMap.getCount());
        }

        System.out.println("--------POST和GET请求量-----------");
        System.out.println("POST请求量为: " + result.getPostMethodCount() + " 个");
        System.out.println("GET请求量为: " + result.getGetMethodCount() + " 个");

        System.out.println("--------按照/AAA分类结果-----------");
        Map<String, Set<String>> classifyURI = result.getClassifyURI();
        Set<Map.Entry<String, Set<String>>> entries = classifyURI.entrySet();
        for (Map.Entry<String, Set<String>> entry : entries) {
            System.out.println("/" + entry.getKey() + " 类下包含的URI：");
            Set<String> value = entry.getValue();
            for (String uriStr : value) {
                System.out.println("URI: " + uriStr);
            }
        }
    }
}
